/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-29 08:42:51
 * @LastEditors: voanit
 * @LastEditTime: 2022-05-29 16:44:13
 */
import { legacy_createStore as createStore, applyMiddleware } from 'redux'
import rootReducers from './reducers'
import thunk, { ThunkAction } from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'
import { TodoAction } from './actions/todo'

// type p1 = typeof store.getState
// type p2 = ReturnType<p1> //  p2就获取了所有的redux中的数据类型
export type RootState = ReturnType<typeof store.getState> //  就获取了所有的redux中的数据类型
const store = createStore(
  rootReducers,
  composeWithDevTools(applyMiddleware(thunk))
)

export type RootThunkAction = ThunkAction<void, RootState, unknown, TodoAction>

console.log(store.getState(), 8811)

export default store
